﻿<template>
	<transition name="el-zoom-in-center">
		<div class="SHZY-preview-main" style='overflow: hidden'>
			<div class="SHZY-common-page-header">
				<el-page-header @back="goBack" :content="!dataForm.id ? '新建' : '编辑'" />

				<div class="options">
					<el-button type="primary" @click="rewardsClick()" :disabled="readOnly">现场调查</el-button>
					<el-button type="primary" @click="correctClick()" :disabled="readOnly">发起纠正和预防措施流程</el-button>
					<el-button type="primary" @click="qualityClick()" :disabled="readOnly">质量申诉</el-button>
					<el-button type="success" @click="dataFormSubmit()" :loading="btnLoading" :disabled="readOnly">保
						存</el-button>

				</div>
			</div>

			<div>

				<el-steps :active="active" finish-status="success" align-center
					style="background-color: white;margin-top: 20px;">
					<el-step title="基本信息" @click.native="stepClick('step1')"></el-step>
					<el-step title="不合格/图片" @click.native="stepClick('step2')"></el-step>

					<el-step title="调查结果" @click.native="stepClick('step3')"></el-step>
					<el-step title="临时对策" @click.native="stepClick('step4')"></el-step>
					<el-step title="作证资料" @click.native="stepClick('step5')"></el-step>
					<el-step title="长期对策" @click.native="stepClick('step6')"></el-step>
					<el-step title="质量损失" @click.native="stepClick('step7')"></el-step>
				</el-steps>

			</div>
			<div style="overflow: auto">
				<div :style="{ margin: '0 auto', width: '100%' }">
					<el-row :gutter="15" class="">
						<el-form ref="elForm" :model="dataForm" size="small" label-width="100px" label-position="right"
							:rules="rules" :disabled="readOnly">
							<el-col :span="24" id="step1">
								<el-form-item label-width="0">
									<groupTitle content-position="left" content="基础信息" style="padding-left: 20px;">
									</groupTitle>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="工单编号" prop="no">
									<el-input v-model='dataForm.no' placeholder='请输入' clearable
										:style='{ "width": "100%" }'>
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="创建人" prop="creatorUserId">


									<user-select v-model='dataForm.creatorUserId' placeholder='请选择' clearable>
									</user-select>

								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="客户编号" prop="customerNo">
									<el-input v-model='dataForm.customerNo' placeholder='请输入' clearable
										:style='{ "width": "100%" }'>
										<el-button slot="append" icon="el-icon-search"
											@click="getcustomer()"></el-button>
									</el-input>
								</el-form-item>
							</el-col>

							<el-col :span="6">
								<el-form-item label="客户名称" prop="customerName">
									<el-input v-model='dataForm.customerName' placeholder='请输入' clearable
										:style='{ "width": "100%" }'>
									</el-input>

								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="反馈阶段" prop="feedbackStage">
									<el-select v-model='dataForm.feedbackStage' placeholder='请选择' clearable
										:style='{ "width": "100%" }'>
										<el-option v-for="(item, index) in feedbackStageOptions" :key="index"
											:label="item.fullName" :value="item.fullName"></el-option>
									</el-select>
								</el-form-item>
							</el-col>

							<el-col :span="6">
								<el-form-item label="反馈人" prop="feedbackUserName">
									<el-input v-model='dataForm.feedbackUserName' placeholder='请输入' clearable
										:style='{ "width": "100%" }'>
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="反馈日期" prop="feedbackDate">
									<el-date-picker v-model='dataForm.feedbackDate' placeholder='请选择' clearable
										:style='{ "width": "100%" }' type='date' format='yyyy-MM-dd'
										value-format='timestamp'>
									</el-date-picker>
								</el-form-item>
							</el-col>

							<el-col :span="6">
								<el-form-item label="反馈方式" prop="feedbackWay">
									<el-select v-model='dataForm.feedbackWay' placeholder='请选择' clearable
										:style='{ "width": "100%" }'>
										<el-option v-for="(item, index) in feedbackWayOptions" :key="index"
											:label="item.fullName" :value="item.fullName"></el-option>
									</el-select>
								</el-form-item>
							</el-col>

							<el-col :span="6">
								<el-form-item label="反馈单号" prop="feedbackNo">
									<el-input v-model='dataForm.feedbackNo' placeholder='请输入' clearable
										:style='{ "width": "100%" }'>
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="抱怨类型" prop="complaintType">
									<el-select v-model='dataForm.complaintType' placeholder='请选择' clearable
										:style='{ "width": "100%" }'>
										<el-option v-for="(item, index) in complaintTypeOptions" :key="index"
											:label="item.fullName" :value="item.fullName"></el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="产品名称" prop="productName">
									<el-input v-model='dataForm.productName' placeholder='请输入' clearable
										:style='{ "width": "100%" }'>
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="缺陷类别" prop="defectCategory">
									<el-select v-model='dataForm.defectCategory' placeholder='请选择' clearable
										:style='{ "width": "100%" }'>
										<el-option v-for="(item, index) in defectCategoryOptions" :key="index"
											:label="item.fullName" :value="item.fullName"></el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="问题归属" prop="problemAttribution">
									<el-select v-model='dataForm.problemAttribution' placeholder='请选择' clearable
										:style='{ "width": "100%" }'>
										<el-option v-for="(item, index) in problems" :key="index" :label="item.fullName"
											:value="item.fullName"></el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="24">
								<el-form-item label="问题描述" prop="problemDescription">
									<el-input v-model='dataForm.problemDescription' type="textarea" maxlength="500"
										show-word-limit placeholder='请输入' clearable :style='{ "width": "100%" }'
										:rows="3">
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="24" id="step2">
								<el-form-item label-width="0">
									<groupTitle content-position="left" content="不合格/图片" style="padding-left: 20px;">
									</groupTitle>
								</el-form-item>
							</el-col>
							<el-col :span="24">
								<el-form-item label-width="0" style="margin-left: 20px; ">

									<el-table :data="dataForm.ImageList" size='mini' border>

										<el-table-column prop="fileInfo" label="文件信息">

											<template slot-scope="scope">
												<el-image style="width: 50px; height: 50px ;cursor: pointer;" :src="url"
													fit="cover" @click="downimage(scope.row.fileInfo)"></el-image>

											</template>
										</el-table-column>
										<el-table-column prop="remark" label="备注">

											<template slot-scope="scope">
												<el-input v-model='scope.row.remark' placeholder='备注' clearable required
													:style='{ "width": "100%" }'>
												</el-input>
											</template>
										</el-table-column><el-table-column prop="creatorUserId" label="上传人">

											<template slot-scope="scope">
												<el-input v-model='scope.row.creatorUserId' placeholder='上传人' clearable
													required :style='{ "width": "100%" }' disabled>
												</el-input>
											</template>
										</el-table-column><el-table-column prop="creatorTime" label="上传日期">

											<template slot-scope="scope">
												<el-date-picker v-model='scope.row.creatorTime' placeholder='请选择'
													clearable :style='{ "width": "100%" }' type='date'
													format='yyyy-MM-dd' value-format='timestamp' disabled>
												</el-date-picker>

											</template>
										</el-table-column>
										<el-table-column label="操作" width="100">
											<template slot-scope="scope">
												<el-button size="mini" type="text"
													@click="addHandleQmsEntityList(scope.row.id, '0')">编辑</el-button>
												<el-button size="mini" type="text" class="SHZY-table-delBtn"
													@click="handleDelQmsEntityList(scope.row.id)">删除</el-button>
											</template>
										</el-table-column>
									</el-table>
									<div class="table-actions" @click="addHandleQmsEntityList('', '0')">
										<el-button type="text" icon="el-icon-plus">新增</el-button>
									</div>
								</el-form-item>
							</el-col>
							<el-col :span="24" id="step3">
								<el-form-item label-width="0">
									<groupTitle content-position="left" content="调查结果" style="padding-left: 20px;">
									</groupTitle>
								</el-form-item>
							</el-col>

							<el-col :span="12">
								<el-form-item label="调查人" prop="checkUserId">
									<user-select v-model='dataForm.checkUserId' placeholder='请选择' clearable
										@change="checkUserConfirm">
									</user-select>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="调查日期" prop="checkDate"
									:rules="showcheckDate == false ? rules.checkDate : [{ required: false, message: '调查日期', trigger: 'change' }]">
									<el-date-picker v-model='dataForm.checkDate' placeholder='请选择' clearable
										:style='{ "width": "100%" }' type='date' format='yyyy-MM-dd'
										value-format='timestamp'>
									</el-date-picker>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="发生原因" prop="checkCause">
									<el-input v-model='dataForm.checkCause' placeholder='请输入' clearable type="textarea"
										@input="checkCauseChange" maxlength="200" show-word-limit
										:style='{ "width": "100%" }'>
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="流出原因" prop="checkCauseOut"
									:rules="showcheck == false ? rules.checkCauseOut : [{ required: false, message: '流出原因', trigger: 'change' }]">
									<el-input v-model='dataForm.checkCauseOut' placeholder='请输入' clearable
										type="textarea" maxlength="200" show-word-limit :style='{ "width": "100%" }'>
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="24">
								<el-form-item label="根本原因" prop="checkCauseRoot"
									:rules="showcheck == false ? rules.checkCauseRoot : [{ required: false, message: '根本原因', trigger: 'change' }]">
									<el-input v-model='dataForm.checkCauseRoot' placeholder='请输入' clearable
										type="textarea" maxlength="500" show-word-limit :style='{ "width": "100%" }'>
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="问题类别" prop="checkProblem"
									:rules="showcheck == false ? rules.checkProblem : [{ required: false, message: '问题类别', trigger: 'change' }]">
									<el-select v-model='dataForm.checkProblem' placeholder='请选择' clearable
										:style='{ "width": "100%" }'>
										<el-option v-for="(item, index) in checkProblemOptions" :key="index"
											:label="item.fullName" :value="item.id"></el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="是否重复" prop="checkDuplicate"
									:rules="showcheck == false ? rules.checkDuplicate : [{ required: false, message: '是否重复', trigger: 'change' }]">
									<el-select v-model='dataForm.checkDuplicate' placeholder='请选择' clearable
										:style='{ "width": "100%" }'>
										<el-option v-for="(item, index) in checkDuplicateOptions" :key="index"
											:label="item.fullName" :value="item.id"></el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="是否重大" prop="checkMajor"
									:rules="showcheck == false ? rules.checkMajor : [{ required: false, message: '是否重大', trigger: 'change' }]">
									<el-select v-model='dataForm.checkMajor' placeholder='请选择' clearable
										:style='{ "width": "100%" }'>
										<el-option v-for="(item, index) in checkMajorOptions" :key="index"
											:label="item.fullName" :value="item.id"></el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="涉及不良数" prop="checkBadNum"
									:rules="showcheck == false ? rules.checkBadNum : [{ required: false, message: '涉及不良数', trigger: 'change' }]">
									<el-input-number v-model='dataForm.checkBadNum' placeholder='0' :step='1' :min="1">
									</el-input-number>
								</el-form-item>
							</el-col>
							<el-col :span="24" id="step4">
								<el-form-item label-width="0">
									<groupTitle content-position="left" content="临时对策" style="padding-left: 20px;">
									</groupTitle>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="反馈现场的处理对策" prop="tcProcessing">
									<el-input v-model='dataForm.tcProcessing' placeholder='请输入' clearable
										type="textarea" maxlength="200" show-word-limit :style='{ "width": "100%" }'
										:rows="3">
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="不良发生的拦截对策" prop="tcIntercept">
									<el-input v-model='dataForm.tcIntercept' placeholder='请输入' clearable type="textarea"
										maxlength="200" show-word-limit :style='{ "width": "100%" }' :rows="3">
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="计划完成时间" prop="tcPlannedDate">
									<el-date-picker v-model='dataForm.tcPlannedDate' placeholder='请选择' clearable
										:style='{ "width": "100%" }' type='date' format='yyyy-MM-dd'
										value-format='timestamp'>
									</el-date-picker>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="责任人" prop="tcResponsible">

									<user-select v-model='dataForm.tcResponsible' placeholder='请选择' clearable>
									</user-select>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="实际完成时间" prop="tcActualDate">

									<el-date-picker v-model='dataForm.tcActualDate' placeholder='请选择' clearable
										:style='{ "width": "100%" }' type='date' format='yyyy-MM-dd'
										value-format='timestamp'>
									</el-date-picker>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="执行状态" prop="tcStatus">


									<el-select v-model='dataForm.tcStatus' placeholder='请选择' clearable
										:style='{ "width": "100%" }'>
										<el-option v-for="(item, index) in tcStatusOptions" :key="index"
											:label="item.fullName" :value="item.id"></el-option>
									</el-select>

								</el-form-item>
							</el-col>

							<el-col :span="24" id="step5">
								<el-form-item label-width="0">
									<groupTitle content-position="left" content="作证资料" style="padding-left: 20px;">
									</groupTitle>
								</el-form-item>
							</el-col>
							<el-col :span="24">
								<el-form-item label-width="0" style="margin-left: 20px; ">

									<el-table :data="dataForm.DataList" size='mini' border>

										<el-table-column prop="fileInfo" label="文件信息">

											<template slot-scope="scope">
												<el-image style="width: 50px; height: 50px;cursor: pointer;" :src="url"
													fit="cover" @click="downimage(scope.row.fileInfo)"></el-image>

											</template>
										</el-table-column>
										<el-table-column prop="remark" label="备注">

											<template slot-scope="scope">
												<el-input v-model='scope.row.remark' placeholder='备注' clearable required
													:style='{ "width": "100%" }'>
												</el-input>
											</template>
										</el-table-column><el-table-column prop="creatorUserId" label="上传人">

											<template slot-scope="scope">
												<el-input v-model='scope.row.creatorUserId' placeholder='上传人' clearable
													required :style='{ "width": "100%" }' disabled>
												</el-input>
											</template>
										</el-table-column><el-table-column prop="creatorTime" label="上传日期">

											<template slot-scope="scope">
												<el-date-picker v-model='scope.row.creatorTime' placeholder='请选择'
													clearable :style='{ "width": "100%" }' type='date'
													format='yyyy-MM-dd' value-format='timestamp' disabled>
												</el-date-picker>

											</template>
										</el-table-column>
										<el-table-column label="操作" width="100">
											<template slot-scope="scope">
												<el-button size="mini" type="text"
													@click="addHandleQmsEntityList(scope.row.id, '1')">编辑</el-button>
												<el-button size="mini" type="text" class="SHZY-table-delBtn"
													@click="handleDelQmsEntityList(scope.row.id)">删除</el-button>
											</template>
										</el-table-column>
									</el-table>
									<div class="table-actions" @click="addHandleQmsEntityList('', '1')">
										<el-button type="text" icon="el-icon-plus">新增</el-button>
									</div>
								</el-form-item>
							</el-col>
							<el-col :span="24" id="step6">
								<el-form-item label-width="0">
									<groupTitle content-position="left" content="长期对策" style="padding-left: 20px;">
									</groupTitle>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="防止发生" prop="lcPrevention">
									<el-input v-model='dataForm.lcPrevention' placeholder='请输入' clearable
										type="textarea" maxlength="200" show-word-limit :style='{ "width": "100%" }'
										:rows="3">
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="防止流出" prop="lcLeakage">
									<el-input v-model='dataForm.lcLeakage' placeholder='请输入' clearable type="textarea"
										maxlength="200" show-word-limit :style='{ "width": "100%" }' :rows="3">
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="计划完成时间" prop="lcPlannedDate">
									<el-date-picker v-model='dataForm.lcPlannedDate' placeholder='请选择' clearable
										:style='{ "width": "100%" }' type='date' format='yyyy-MM-dd'
										value-format='timestamp'>
									</el-date-picker>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="责任人" prop="lcResponsible">
									<user-select v-model='dataForm.lcResponsible' placeholder='请选择' clearable>
									</user-select>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="实际完成时间" prop="lcActualDate">
									<el-date-picker v-model='dataForm.lcActualDate' placeholder='请选择' clearable
										:style='{ "width": "100%" }' type='date' format='yyyy-MM-dd'
										value-format='timestamp'>
									</el-date-picker>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="执行状态" prop="lcStatus">


									<el-select v-model='dataForm.lcStatus' placeholder='请选择' clearable
										:style='{ "width": "100%" }'>
										<el-option v-for="(item, index) in lcStatusOptions" :key="index"
											:label="item.fullName" :value="item.id"></el-option>
									</el-select>

								</el-form-item>
							</el-col>
							<el-col :span="24" id="step7">
								<el-form-item label-width="0">
									<groupTitle content-position="left" content="质量损失" style="padding-left: 20px;">
									</groupTitle>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="责任部门" prop="qualityDept">


									<el-select v-model='dataForm.qualityDept' placeholder='请选择' clearable
										:style='{ "width": "100%" }' :disabled="qualityShow">
										<el-option v-for="(item, index) in qualityDeptOptions" :key="index"
											:label="item.fullName" :value="item.id"></el-option>
									</el-select>

								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="责任人" prop="qualityResponsible">

									<user-select v-model='dataForm.qualityResponsible' placeholder='请选择' clearable
										:disabled="qualityShow">
									</user-select>


								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="责任主管" prop="qualityManager">
									<user-select v-model='dataForm.qualityManager' placeholder='请选择' clearable
										:disabled="qualityShow">
									</user-select>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="材料费" prop="qualityMaterial">
									<el-input v-model='dataForm.qualityMaterial' placeholder='请输入' clearable
										type="number" :min="0" @input="sumMoney" :style='{ "width": "100%" }'
										:disabled="qualityShow">
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="返工费" prop="qualityRework">
									<el-input v-model='dataForm.qualityRework' placeholder='请输入' clearable type="number"
										:min="0" @input="sumMoney" :style='{ "width": "100%" }' :disabled="qualityShow">
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="运输费" prop="qualityFreight">
									<el-input v-model='dataForm.qualityFreight' placeholder='请输入' clearable
										type="number" :min="0" @input="sumMoney" :style='{ "width": "100%" }'
										:disabled="qualityShow">
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="差旅费" prop="qualityTravel">
									<el-input v-model='dataForm.qualityTravel' placeholder='请输入' clearable type="number"
										:min="0" @input="sumMoney" :style='{ "width": "100%" }' :disabled="qualityShow">
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="客户扣款" prop="qualityCDeductions">
									<el-input v-model='dataForm.qualityCDeductions' placeholder='请输入' clearable
										type="number" :min="0" @input="sumMoney" :style='{ "width": "100%" }'
										:disabled="qualityShow">
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="预估挽回损失" prop="qualityEstimated">
									<el-input v-model='dataForm.qualityEstimated' placeholder='请输入' clearable
										type="number" :min="0" @input="sumMoney" :style='{ "width": "100%" }'
										:disabled="qualityShow">
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="合计金额" prop="qualityTotalAmount">
									<el-input v-model='dataForm.qualityTotalAmount' placeholder='' clearable
										:style='{ "width": "100%" }' :disabled='true'>
									</el-input>
								</el-form-item>
							</el-col>
							<el-col :span="24">
								<el-form-item label="备注" prop="remark">
									<el-input v-model='dataForm.remark' placeholder='请输入' clearable type="textarea"
										maxlength="500" show-word-limit :style='{ "width": "100%" }' :rows="3"
										:disabled="qualityShow">
									</el-input>
								</el-form-item>
							</el-col>
						</el-form>
					</el-row>

				</div>
			</div>
			<elevator v-if="formVisible" ref="elevator" />
			<QualityAppeal v-if="QualityAppealVisible" ref="QualityAppeal" />
			<correct v-if="correctVisible" ref="correct" />
			<customer v-if="customerVisible" ref="customer" @confirm="customerConfirm" />
			<file v-if="fileVisible" ref="file" @confirm="FileConfirm" />
		</div>
	</transition>

</template>
<script>
import { getOrganizeList } from '@/api/permission/organize'
import customerAPI from '@/api/q1/business/customer';
import elevator from '@/views/q1/business/complaintCustomer/elevator'
import QualityAppeal from './QualityAppeal.vue'
import correct from './correct.vue'
import customer from './customer.vue'
import file from './file.vue'
export default {
	components: { elevator, QualityAppeal, correct, customer, file },
	props: [],
	data() {
		return {
			qualityShow: true,
			readOnly: false,
			url: require('@/assets/images/icon_file.png'),
			btnLoading: false,
			loading: false,
			visible: false,
			formVisible: false,
			QualityAppealVisible: false,
			correctVisible: false,
			customerVisible: false,
			fileVisible: false,
			active: 0,
			showcheckDate: true,
			showcheck: true,
			dataForm: {
				id: '',
				no: undefined,
				customerNo: undefined,
				customerName: undefined,
				feedbackStage: undefined,
				feedbackUserName: undefined,
				feedbackDate: undefined,
				feedbackWay: undefined,
				feedbackNo: undefined,
				complaintType: undefined,
				productName: undefined,
				defectCategory: undefined,
				problemDescription: undefined,
				checkUserId: undefined,
				checkDate: undefined,
				checkCause: undefined,
				checkCauseOut: undefined,
				checkCauseRoot: undefined,
				checkProblem: undefined,
				checkDuplicate: undefined,
				checkMajor: undefined,
				checkBadNum: undefined,
				tcProcessing: undefined,
				tcIntercept: undefined,
				tcPlannedDate: undefined,
				tcResponsible: undefined,
				tcActualDate: undefined,
				lcStatus: undefined,
				lcPrevention: undefined,
				lcLeakage: undefined,
				lcPlannedDate: undefined,
				lcResponsible: undefined,
				lcActualDate: undefined,
				tcStatus: undefined,
				qualityDept: undefined,
				qualityResponsible: undefined,
				qualityManager: undefined,
				qualityMaterial: undefined,
				qualityRework: undefined,
				qualityFreight: undefined,
				qualityTravel: undefined,
				qualityCDeductions: undefined,
				qualityEstimated: undefined,
				qualityTotalAmount: undefined,
				remark: undefined,
				cancelUserId: undefined,
				cancelDate: undefined,
				status: undefined,
				creatorUserId: undefined,
				creatorTime: undefined,
				lastModifyUserId: undefined,
				lastModifyTime: undefined,
				ImageList: [],
				DataList: [],
				problemAttribution: undefined,
			},
			rules: {

				no: [{ required: true, message: '请填写工单号', trigger: 'blur' },],
				creatorUserId: [{ required: true, message: '请填写创建人', trigger: 'blur' },],
				customerNo: [{ required: true, message: '请选择客户编号', trigger: 'blur' },],
				customerName: [{ required: true, message: '请填写客户名称', trigger: 'blur' },],
				feedbackNo: [{ required: true, message: '请填写反馈单号', trigger: 'blur' },],
				problemAttribution: [{ required: true, message: '请选择问题归属', trigger: 'blur' },],
				feedbackStage: [{ required: true, message: '请选择反馈类型', trigger: 'blur' },],
				feedbackUserName: [{ required: true, message: '请输入反馈人', trigger: 'blur' },],
				feedbackDate: [{ required: true, message: '请选择反馈日期', trigger: 'blur' },],
				feedbackWay: [{ required: true, message: '请选择反馈方式', trigger: 'blur' },],
				complaintType: [{ required: true, message: '请选择抱怨类型', trigger: 'blur' },],
				productName: [{ required: true, message: '请输入产品名称', trigger: 'blur' },],
				defectCategory: [{ required: true, message: '请选择缺陷类别', trigger: 'blur' },],
				problemDescription: [{ required: true, message: '请输入问题描述', trigger: 'blur' },],
				checkDate: [{ required: true, message: '请选择调查日期', trigger: 'blur', },],

				checkCauseOut: [{ required: true, message: '请填写流出原因', trigger: 'blur', },],
				checkCauseRoot: [{ required: true, message: '请填写根本原因', trigger: 'blur', },],
				checkProblem: [{ required: true, message: '请选择问题类别', trigger: 'blur', },],
				checkDuplicate: [{ required: true, message: '请选择是否重复', trigger: 'blur', },],
				checkMajor: [{ required: true, message: '请选择是否重大', trigger: 'blur', },],
				checkBadNum: [{ required: true, message: '请填写涉及不良数', trigger: 'blur', },],
			},
			feedbackStageOptions: [],
			feedbackWayOptions: [],
			complaintTypeOptions: [],
			defectCategoryOptions: [],
			checkProblemOptions: [],
			problems: [],
			checkDuplicateOptions: [{ 'fullName': "是", 'id': '1' }, { 'fullName': "否", 'id': '2' }],
			checkMajorOptions: [{ 'fullName': "是", 'id': '1' }, { 'fullName': "否", 'id': '2' }],
			tcStatusOptions: [{ 'fullName': "关闭", 'id': 1 }, { 'fullName': "未关闭", 'id': 2 }],
			lcStatusOptions: [{ 'fullName': "关闭", 'id': 1 }, { 'fullName': "未关闭", 'id': 2 }],
			qualityDeptOptions: [],
			imageUrl: '',

		}
	},
	computed: {

	},
	watch: {},
	created() {

		//获取部门
		getOrganizeList().then(res => {

			this.qualityDeptOptions = res.data.list[0].children;
		});
		this.dataForm.creatorUserId = this.$store.state.user.userInfo.userId
		//console.log("🚀 ~ this.dataForm.creatorUserId:", this.dataForm.creatorUserId)
	},
	mounted() {
	},
	methods: {


		getDictionaryData() {
			const a = {
				FeedbackPhase: 'feedbackStageOptions', //反馈阶段
				feedbackSystem: 'feedbackWayOptions',//反馈方式
				ComplaintType: 'complaintTypeOptions',//抱怨类型
				DefectClass: 'defectCategoryOptions',//缺陷类别
				problemType: 'checkProblemOptions',
				problem: 'problems'//问题归属
			};
			for (const i in a) {
				this.$store
					.dispatch('base/getDictionaryData', {
						sort: i,
					})
					.then(res => {
						this[a[i]] = res;
					});
			}


		},
		goBack() {
			this.$emit('refresh')
		},
		init(id) {
			this.getDictionaryData();
			this.dataForm.id = id || 0;
			console.log("🚀 ~ this.dataForm.id:", this.dataForm.id)
			this.visible = true;

			this.$nextTick(() => {
				this.$refs['elForm'].resetFields();
				if (this.dataForm.id) {
					customerAPI.qmsbusicustomercomplaintByid(this.dataForm.id).then(res => {
						this.dataForm = res.data;

						if (this.dataForm.checkUserId) {
							this.showcheckDate = false
						} else {
							this.showcheckDate = true
						}

						if (this.dataForm.checkCause) {
							this.showcheck = false
						} else {
							this.showcheck = true
						}

						//登陆人是否是创建人
						if (this.dataForm.creatorUserId == this.$store.state.user.userInfo.userId) {
							this.qualityShow = false
						} else {
							this.qualityShow = true
						}

						if (this.dataForm.status == 4 || this.dataForm.status == 3) {
							this.readOnly = true

						} else {

							if (this.$store.state.user.userInfo.userId != this.dataForm.creatorUserId && this.$store.state.user.userInfo.userId != this.dataForm.checkUserId && this.$store.state.user.userInfo.userId != this.dataForm.tcResponsible && this.$store.state.user.userInfo.userId != this.dataForm.lcResponsible && this.$store.state.user.userInfo.userId != this.dataForm.qualityResponsible) {
								this.readOnly = true
							}


							this.readOnly = false
						}

					})
				} else {
					customerAPI.CreateWorkerCode().then(res => {
						this.dataForm.no = res.data;

					})
				}
			});


		},
		dataFormSubmit() {
			if (this.dataForm.tcStatus == 2 && this.dataForm.lcStatus == 1) {
				this.$message({
					message: '请确保临时对策已关闭',
					type: 'error',
					duration: 1000,

				})

				return
			}
			this.$refs['elForm'].validate((valid) => {
				if (valid) {
					this.btnLoading = true;
					if (!this.dataForm.id) {

						//新增
						customerAPI.insertQmsbusicustomercomplaint(this.dataForm).then(res => {
							this.$message({
								message: res.msg,
								type: 'success',
								duration: 1000,
								onClose: () => {
									this.btnLoading = false;
									this.visible = false,
										this.$emit('refresh', true)
								}
							})

						})
					} else {

						//修改
						customerAPI.updateQmsbusicustomercomplaint(this.dataForm).then(res => {

							this.$message({
								message: res.msg,
								type: 'success',
								duration: 1000,
								onClose: () => {
									this.btnLoading = false;
									this.visible = false
									this.$emit('refresh', true)
								}
							})
						})
					}
				}
			})
		},
		addHandleQmsEntityList(id, type) {

			if (this.dataForm.id) {
				this.fileVisible = true;
				this.$nextTick(() => {
					this.$refs.file.init(this.dataForm.id, id, type)
				})
			} else {
				this.$message({
					message: '请先保存,再添加文件',
					type: 'error',
					duration: 1000,

				})

			}
		},
		handleDelQmsEntityList(id) {

			this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
				type: 'warning'
			}).then(() => {
				customerAPI.deleteqmsbusicustomerfile(id).then(res => {

					this.dataForm.ImageList = res.ImageList;
					this.dataForm.DataList = res.DataList;
				})
			}).catch(() => {
			});




		},
		rewardsClick() {

			this.formVisible = true;
			this.$nextTick(() => {
				this.$refs.elevator.init(this.dataForm)
			})
		},

		qualityClick() {

			if (this.dataForm.qualityResponsible) {
				this.QualityAppealVisible = true;
				this.$nextTick(() => {
					this.$refs.QualityAppeal.init(this.dataForm)
				})
			} else {

				this.$message({
					message: '请先填写质量损失责任人',
					type: 'error',
					duration: 1000,

				})

			}

		},
		correctClick() {

			this.correctVisible = true;
			this.$nextTick(() => {
				this.$refs.correct.init(this.dataForm)
			})
		},
		stepClick(e) {
			if (e != "") {
				//console.log("🚀 ~ e:", e.slice(-1))
				this.active = Number(e.slice(-1));

			}
			document.querySelector('#' + e + '').scrollIntoView();

		},
		getcustomer() {

			this.customerVisible = true;
			this.$nextTick(() => {
				this.$refs.customer.initData()
			})
		},
		customerConfirm(row) {

			this.dataForm.customerNo = row.code
			this.dataForm.customerName = row.name

		},
		FileConfirm(res) {

			this.dataForm.ImageList = res.ImageList;
			this.dataForm.DataList = res.DataList;


		},
		//是否填写调查人
		checkUserConfirm(val) {
			if (val) {
				this.showcheckDate = false
			} else {
				this.showcheckDate = true
			}
		},
		checkCauseChange(val) {
			if (val) {
				this.showcheck = false
			} else {
				this.showcheck = true
			}
		},
		downimage(file) {

			this.shzy.downloadFile(file[0].url)
		},
		sumMoney() {

			this.dataForm.qualityTotalAmount = (Number(this.dataForm.qualityMaterial) * 10000 + Number(this.dataForm.qualityRework) * 10000 + Number(this.dataForm.qualityFreight) * 10000 + Number(this.dataForm.qualityTravel) * 10000 + Number(this.dataForm.qualityCDeductions) * 10000 - Number(this.dataForm.qualityEstimated) * 10000) / 10000

		}


	}
}
</script>

<style scoped></style>
